<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2016/9/8
  Time: 15:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="../common/include.jsp" %>
<html>

<head>
    <title>Title</title>

    <!-- css -->


    <link href="components/kindeditor-4.1.10/themes/default/default.css" rel="stylesheet"/>


    <script type="text/javascript" src="js/jquery.ajaxContent.pack.js"></script>

    <script type="text/javascript" src="js/ajaxfileupload.js" charset="utf-8"></script>

    <script type="text/javascript" src="components/kindeditor-4.1.10/kindeditor.js"></script>
    <script type="text/javascript" src="components/kindeditor-4.1.10/plugins/code/prettify.js"></script>
    <script type="text/javascript" src="components/kindeditor-4.1.10/lang/zh_CN.js"></script>
    <script type="text/javascript" src="js/jquery.sortable.js" charset="utf-8"></script>

    <script type="text/javascript">
        var serverIp = "localhost:8080";
        var editor1 = null;
        $(function () {
            //时间选择器
            laydate.render({
                elem: '#feedback_time'
                ,type: 'datetime'
            });

            KindEditor.ready(function (K) {
                editor1 = K.create("textarea[name='detail']", {
                    uploadJson: 'kindUploadt1.html',
                    allowUpload: true, //允许上传图,
                    urlType: 'domain',
                    afterCreate: function () {
                        var doc = this.edit.doc;
                        var cmd = this.edit.cmd;
                        $(doc.body).bind('paste', function (ev) {
                            var $this = $(this);
                            var dataItem = ev.originalEvent.clipboardData.items[0];
                            if (dataItem) {
                                var file = dataItem.getAsFile();
                                if (file) {
                                    var reader = new FileReader();
                                    reader.onload = function (evt) {
                                        var imageDataBase64 = evt.target.result;
                                        $.post("imgUpload/base64.html", {
                                            "imageDataBase64": imageDataBase64
                                        }, function (resp) {
                                            var respData = resp;
                                            respData = jQuery.parseJSON(respData);
                                            if (respData.errCode == 0) {
                                                var html = '<a target="_blank" href="' + respData.url + '"><img style="height: 300px" src="' + respData.url + '" alt="" /></a>';
                                                cmd.inserthtml(html);
                                            }
                                        });
                                    };
                                    reader.readAsDataURL(file);
                                }
                            }
                        });
                    },
                    afterBlur: function () {
                        this.sync();
                    }
                });
            });
        });
        window.prettyPrint();

        //记录选择的选项卡
        var demandType = 0;

        function changeTab(tabid) {
            $("#demandType").val(tabid);
            if (demandType != tabid) {
                //                $("#demandForm")[0].reset();
                demandType = tabid;
                if (1 == tabid) {
                    $("#departments").show();
                    $("#priorityDiv").show();
                    $("#principalDiv").show();
                } else {
                    $("#departments").hide();
                    $("#priorityDiv").hide();
                    $("#principalDiv").hide();
                    $("#kfzz").hide();
                }

                if (3 == tabid) {
                    $("#operationDiv").show();
                    $("#statusDiv").show();
                    $("#typeDiv").show();
                } else {
                    $("#operationDetail").val();
                    $("#operationDiv").hide();
                    $("#status").val(1);
                    $("#statusDiv").hide();
                    $("#typeDiv").hide();
                    $("#opType").val(1);
                }

                if (2 == tabid) {
                    $("#kfzz").show();
                } else {
                    $("#kfzz").hide();
                }
            }
        }

        //部门关联人员
        function getDepartmentManager() {
            var department = $("#department").val();
            $("#departError").css('display', 'none');
            if ("请选择--" == department) {
                return;
            }

            var args = {
                "departmentId": department
            };

            var url = "getManagerByDepartmentId.html"
            //加载进度条
            layer.load(2, {
                shade: [0.2, '#999999'] //0.1透明度的白色背景
            });
            $.post(url, args, function (data) {
                data = jQuery.parseJSON(data);

                //保存成功
                if (data.code == 1) {
                    layer.closeAll('loading');
                    var users = data.body;

                    var htmlStr = "<option selected>请选择--</option>";
                    for (var i = 0; i < users.length; i++) {
                        htmlStr += "<option value='" + users[i].id + "'>" + users[i].realName + "</option>"
                    }

                    $("#principal").html(htmlStr);

                } else {
                    //失败
                    layer.closeAll('loading');
                }
            });


        }
    </script>
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content  animated fadeInRight">
    <form class="form-horizontal" id="demandForm" name="demandForm">
        <input type="hidden" value="${demand.id}" id="opId">
        <input type="hidden" value="${demandType}" id="demandType">
        <input type="hidden" value="${demandType}" id="oldDemandType">
        <div class="tabs-container">
            <ul class="nav nav-tabs">
                <c:if test="${demandType == 3}">
                    <li
                            class='active'>
                        <a data-toggle="tab" href="#" onclick="changeTab(3)" aria-expanded="true"> <i
                                class="fa fa-hand-pointer-o"></i> 操作</a>
                    </li>
                </c:if>
                <c:if test="${demandType == 1}">
                    <li
                            class='active'>
                        <a data-toggle="tab" href="#" onclick="changeTab(1)" aria-expanded="false"> <i
                                class="fa fa-bolt"></i> BUG</a>
                    </li>
                </c:if>
                <c:if test="${demandType == 2}">
                    <li
                            class='active'>
                        <a data-toggle="tab" href="#" onclick="changeTab(2)" aria-expanded="false"> <i
                                class="fa fa-book"></i> 需求</a>
                    </li>
                </c:if>

            </ul>
            <div class="tab-content">
                <div id="tab-1" class="tab-pane active">
                    <div class="panel-body">
                        <fieldset>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">标题<span
                                        style="color: red ;font-size:18px">*</span>：</label>
                                <div class="col-sm-4">
                                    <select id="title" name="title" class="form-control" required=""
                                            aria-required="true">
                                        <option>请选择---</option>
                                        <c:forEach items="${titleList}" var="title">
                                            <option value="${title.id}" <c:if test="${title.title == demand.title}">selected</c:if>>${title.title}</option>
                                        </c:forEach>

                                    </select>

                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">问题产品<span
                                        style="color: red ;font-size:18px">*</span>：</label>
                                <div class="col-sm-4">
                                    <select id="demand_product" name="demand_product" class="form-control" required=""
                                            aria-required="true">
                                        <option>请选择---</option>
                                        <c:forEach items="${productList}" var="product">
                                            <option value="${product.id}"
                                                    <c:if test="${product.id == demand.demandProduct}">selected</c:if>>${product.product_name}</option>
                                        </c:forEach>

                                    </select>
                                </div>
                                <label class="col-sm-2 control-label">反馈来源<span
                                        style="color: red ;font-size:18px">*</span>：</label>
                                <div class="col-sm-4">
                                    <select class="form-control" name="feedback_source" id="feedback_source">
                                        <option
                                                <c:if test="${'QQ' == demand.feedbackSource}">selected</c:if> value="1">
                                            QQ
                                        </option>
                                        <option
                                                <c:if test="${'微信' == demand.feedbackSource}">selected</c:if> value="2">
                                            微信
                                        </option>
                                        <option
                                                <c:if test="${'电话' == demand.feedbackSource}">selected</c:if> value="3">
                                            电话
                                        </option>
                                        <option
                                                <c:if test="${'直接到访' == demand.feedbackSource}">selected</c:if>
                                                value="4">直接到访
                                        </option>
                                    </select>
                                </div>
                            </div>


                            <div class="form-group">
                                <label class="col-sm-2 control-label">反馈城市<span
                                        style="color: red ;font-size:18px">*</span>：</label>
                                <div class="col-sm-4">

                                    <select class="form-control" name="feedback_city" id="feedback_city">
                                        <option
                                                <c:if test="${demand.feedbackCity == '集团'}">selected</c:if> value="130">
                                            集团
                                        </option>
                                        <option
                                                <c:if test="${demand.feedbackCity == '南昌'}">selected</c:if> value="104">
                                            南昌
                                        </option>
                                        <option
                                                <c:if test="${demand.feedbackCity == '太原'}">selected</c:if> value="101">
                                            太原
                                        </option>
                                        <option
                                                <c:if test="${demand.feedbackCity == '长沙'}">selected</c:if> value="102">
                                            长沙
                                        </option>
                                        <option
                                                <c:if test="${demand.feedbackCity == '郑州'}">selected</c:if> value="100">
                                            郑州
                                        </option>
                                        <option
                                                <c:if test="${demand.feedbackCity == '成都'}">selected</c:if> value="106">
                                            成都
                                        </option>
                                        <option
                                                <c:if test="${demand.feedbackCity == '昆明'}">selected</c:if> value="107">
                                            昆明
                                        </option>
                                        <option
                                                <c:if test="${demand.feedbackCity == '石家庄'}">selected</c:if>
                                                value="108">石家庄
                                        </option>
                                        <option
                                                <c:if test="${demand.feedbackCity == '武汉'}">selected</c:if> value="109">
                                            武汉
                                        </option>
                                        <option
                                                <c:if test="${demand.feedbackCity == '乌鲁木齐'}">selected</c:if>
                                                value="110">乌鲁木齐
                                        </option>
                                        <option
                                                <c:if test="${demand.feedbackCity == '南京'}">selected</c:if> value="111">
                                            南京
                                        </option>
                                        <option
                                                <c:if test="${demand.feedbackCity == '九江'}">selected</c:if> value="114">
                                            九江
                                        </option>
                                        <option
                                                <c:if test="${demand.feedbackCity == '重庆'}">selected</c:if> value="116">
                                            重庆
                                        </option>
                                        <option
                                                <c:if test="${demand.feedbackCity == '泰州'}">selected</c:if> value="112">
                                            泰州
                                        </option>
                                        <option
                                                <c:if test="${demand.feedbackCity == '福州'}">selected</c:if> value="113">
                                            福州
                                        </option>
                                        <option
                                                <c:if test="${demand.feedbackCity == '沈阳'}">selected</c:if> value="115">
                                            沈阳
                                        </option>
                                        <option
                                                <c:if test="${demand.feedbackCity == '宜春'}">selected</c:if> value="117">
                                            宜春
                                        </option>

                                    </select>


                                </div>
                                <label class="col-sm-2 control-label">反馈人<span
                                        style="color: red ;font-size:18px">*</span>：</label>
                                <div class="col-sm-4">
                                    <input name="feedback_name" value="${demand.feedbackName}" id="feedback_name"
                                           type="text" class="form-control">
                                </div>

                            </div>

                            <div class="form-group">

                                <label class="col-sm-2 control-label">反馈时间<span
                                        style="color: red ;font-size:18px">*</span>：</label>
                                <div class="col-sm-4">
                                    <div class="input-group date">
                                        <span class="input-group-addon"
                                                class="fa fa-calendar"></i></span>
                                        <input readonly name="feedback_time" id="feedback_time"
                                               value="${demand.feedbackTime}"
                                               type="text" class="form-control">

                                    </div>
                                    <span style="display: none;color: #cc5965;margin-left: 5px" id="feedbackTimeError"
                                          for="feedback_time">请填写反馈时间</span>

                                </div>

                                <!-- 处理状态-->
                                <c:if test="${demandType == 3}">
                                <div id="statusDiv" style='display: block'></c:if>
                                    <c:if test="${demandType != 3}">
                                    <div id="statusDiv" style='display: none'></c:if>
                                        <label class="col-sm-2 control-label">处理状态<span
                                                style="color: red ;font-size: 18px">*</span>：</label>
                                        <div class="col-sm-4">
                                            <select class="form-control" name="status"
                                                    id="status">
                                                <option value="1" <c:if test="${demand.status == 1}">selected</c:if>>
                                                    未处理
                                                </option>
                                                <option value="2" <c:if test="${demand.status == 2}">selected</c:if>>
                                                    已处理
                                                </option>
                                            </select>
                                        </div>

                                    </div>


                                    <!-- 部门列表-->
                                    <c:if test="${demandType == 1}">
                                        <div id="departments" style="display:block">


                                            <label class="col-sm-2 control-label">处理部门<span
                                                    style="color: red ;font-size:18px">*</span>：</label>
                                            <div class="col-sm-4">
                                                <select onchange="getDepartmentManager()" class="form-control"
                                                        name="department"
                                                        id="department">
                                                    <option>请选择--</option>
                                                    <c:forEach items="${departmentList}" var="det">
                                                        <option
                                                                <c:if test="${demand.departmentId==det.id}">selected</c:if>
                                                                value="${det.id}">${det.name}</option>

                                                    </c:forEach>
                                                </select>
                                                <span style="display: none;color: #cc5965;margin-left: 5px"
                                                      id="departError"
                                                      for="detail">请选择部门</span>
                                            </div>

                                        </div>
                                    </c:if>
                                    <c:if test="${demandType != 1}">
                                        <div id="departments" style="display:none">
                                            <label class="col-sm-2 control-label">处理部门<span
                                                    style="color: red ;font-size:18px">*</span>：</label>
                                            <div class="col-sm-4">
                                                <select onchange="getDepartmentManager()" class="form-control"
                                                        name="department"
                                                        id="department">
                                                    <option>请选择--</option>
                                                    <c:forEach items="${departmentList}" var="det">
                                                        <option value="${det.id}">${det.name}</option>

                                                    </c:forEach>
                                                </select>
                                                <span style="display: none;color: #cc5965;margin-left: 5px"
                                                      id="departError"
                                                      for="detail">请选择部门</span>
                                            </div>

                                        </div>
                                    </c:if>

                                    <!-- 选择客服组长-->
                                    <c:if test="${demandType == 2}">
                                        <div id="kfzz" style="display:block">
                                            <label class="col-sm-2 control-label">客服组长<span
                                                    style="color: red ;font-size:18px">*</span>：</label>
                                            <div class="col-sm-4">
                                                <select class="form-control" name="currentPrincipal"
                                                        id="currentPrincipal">
                                                    <c:forEach items="${kfzz}" var="det">
                                                        <option value="${det.id}">${det.realName}</option>
                                                    </c:forEach>
                                                </select>
                                            </div>

                                        </div>
                                    </c:if>
                                    <c:if test="${demandType != 2}">
                                        <div id="kfzz" style="display:none">
                                            <label class="col-sm-2 control-label">客服组长<span
                                                    style="color: red ;font-size:18px">*</span>：</label>
                                            <div class="col-sm-4">
                                                <select class="form-control" name="currentPrincipal"
                                                        id="currentPrincipal">
                                                    <c:forEach items="${kfzz}" var="det">
                                                        <option value="${det.id}">${det.realName}</option>
                                                    </c:forEach>
                                                </select>

                                            </div>

                                        </div>
                                    </c:if>

                                </div>

                                <div class="form-group">
                                    <c:if test="${demandType == 1}">
                                        <div id="priorityDiv" style="display:block">


                                            <label class="col-sm-2 control-label">紧急度<span
                                                    style="color: red ;font-size:18px">*</span>：</label>
                                            <div class="col-sm-4">
                                                <select class="form-control" name="priority" id="priority">

                                                    <option <c:if test="${demand.priority == 1}">selected</c:if> value="1">一级</option>
                                                    <option <c:if test="${demand.priority == 2}">selected</c:if> value="2">二级</option>
                                                    <option <c:if test="${demand.priority == 3}">selected</c:if> value="3">三级</option>
                                                    <option <c:if test="${demand.priority == 4}">selected</c:if> value="4">四级</option>
                                                    <option <c:if test="${demand.priority == 5}">selected</c:if> value="5">五级</option>
                                                </select>
                                            </div>
                                        </div>
                                    </c:if>
                                    <c:if test="${demandType != 1}">
                                        <div id="priorityDiv" style="display:none">
                                            <label class="col-sm-2 control-label">紧急度<span
                                                    style="color: red ;font-size:18px">*</span>：</label>
                                            <div class="col-sm-4">
                                                <select class="form-control" name="priority" id="priority">

                                                    <option  value="1">一级</option>
                                                    <option  value="2">二级</option>
                                                    <option  value="3">三级</option>
                                                    <option value="4">四级</option>
                                                    <option  value="5">五级</option>
                                                </select>
                                            </div>
                                        </div>
                                    </c:if>

                                    <!-- 部门项目经理-->
                                    <c:if test="${demandType == 1}">
                                        <div id="principalDiv" style="display:block">


                                            <label class="col-sm-2 control-label">项目经理<span
                                                    style="color: red ;font-size:18px">*</span>：</label>
                                            <div class="col-sm-4">
                                                <select class="form-control" name="principal" id="principal">
                                                    <option value="${demand.principalId}">${demand.principal}</option>
                                                </select>
                                                <span style="display: none;color: #cc5965;margin-left: 5px"
                                                      id="priError"
                                                      for="detail">请选择项目经理</span>
                                            </div>

                                        </div>
                                    </c:if>
                                    <c:if test="${demandType != 1}">
                                        <div id="principalDiv" style="display:none">
                                            <label class="col-sm-2 control-label">项目经理<span
                                                    style="color: red ;font-size:18px">*</span>：</label>
                                            <div class="col-sm-4">
                                                <select class="form-control" name="principal" id="principal">
                                                    <option>请选择</option>
                                                </select>
                                                <span style="display: none;color: #cc5965;margin-left: 5px"
                                                      id="priError"
                                                      for="detail">请选择项目经理</span>
                                            </div>
                                        </div>
                                    </c:if>
                                </div>

                                <div class="form-group">
                                    <label class="col-sm-2 control-label">录入时间<span
                                            style="color: red ;font-size:18px">*</span>：</label>
                                    <div class="col-sm-4">
                                        <div class="input-group date">
                                                        <span class="input-group-addon"><i
                                                                class="fa fa-calendar"></i></span>
                                            <input readonly name="create_time" id="create_time" type="text"
                                                   value="${demand.createTime}" class="form-control">

                                        </div>
                                        <span style="display: none;color: #cc5965;margin-left: 5px"
                                              id="createTimeError"
                                              for="create_time">请填写录入时间</span>

                                    </div>


                                    <!-- 操作分类-->
                                    <c:if test="${demandType == 3}">
                                        <div id="typeDiv">
                                            <label class="col-sm-2 control-label">分类<span
                                                    style="color: red ;font-size: 18px">*</span>：</label>
                                            <div class="col-sm-4">
                                                <select class="form-control" name="opType"
                                                        id="opType">
                                                    <option value="1"
                                                            <c:if test="${demand.optype == '操作'}">selected</c:if>>操作
                                                    </option>
                                                    <option value="2"
                                                            <c:if test="${demand.optype == '咨询'}">selected</c:if>>咨询
                                                    </option>

                                                </select>
                                            </div>

                                        </div>
                                    </c:if>
                                    <c:if test="${demandType != 3}">
                                        <div id="typeDiv" style="display: none">
                                            <label class="col-sm-2 control-label">分类<span
                                                    style="color: red ;font-size: 18px">*</span>：</label>
                                            <div class="col-sm-4">
                                                <select class="form-control" name="opType"
                                                        id="opType">
                                                    <option value="1">操作</option>
                                                    <option value="2">咨询</option>

                                                </select>
                                            </div>

                                        </div>
                                    </c:if>

                                </div>

                                <div class="form-group">
                                    <label class="col-sm-2 control-label">问题描述：</label>
                                    <div class="col-sm-10">
                                    <textarea required="" id="detail" name="detail" class="form-control"
                                              rows="5">${demand.detail}</textarea>
                                        <span style="display: none;color: #cc5965;margin-left: 5px"
                                              id="detailError"
                                              for="detail">请填写问题描述</span>
                                    </div>
                                </div>


                        </fieldset>


                        <fieldset>
                            <div class="form-group">
                                <div class="col-sm-7" style="text-align: right;margin-top: 30px">

                                    <input value="提交内容" class="btn  btn-primary" type="button" id="submitBtn">
                                    <button onclick="closeWin()" class="btn  btn--white" type="reset">关闭</button>
                                </div>
                            </div>
                        </fieldset>
                    </div>


                </div>

            </div>


        </div>


        <!--<fieldset>-->
        <!--<legend>字段名</legend>-->
        <!--<div class="form-group">-->
        <!--<label for="disabledSelect" class="col-sm-2 control-label">表名</label>-->
        <!--<div class="col-sm-10">-->
        <!--<select id="disabledSelect" class="form-control">-->
        <!--<option>禁止选择</option>-->
        <!--<option>禁止选择</option>-->
        <!--</select>-->
        <!--</div>-->
        <!--</div>-->
        <!--</fieldset>-->
    </form>
</div>


<script>
    function closeWin() {
        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index); //再执行关闭
    }

    $(document).ready(function () {
        $("#demandForm").validate({

            rules: {

                title: {
                    min: 0,
                },
                department: {
                    min: 0,
                },
                principal: {
                    min: 0,
                },
                feedback_name: {
                    required: true,
                },
                feedback_city: {
                    required: true,
                },
                demand_product: {
                    min: 0,
                },
                demand_type: {
                    min: 0,
                },
                feedback_source: {
                    min: 0,
                },
            },
            messages: {

                feedback_name: {
                    required: '请填写反馈人姓名'
                },
                title: {
                    min: '请填写标题'
                },
                department: {
                    min: '请选择部门'
                },
                principal: {
                    min: '请选择项目经理'
                },

                feedback_city: {
                    required: '请填写反馈人城市'
                },
                demand_product: {
                    min: '请选择问题产品'
                },
                demand_type: {
                    min: '请选择问题类型'
                },
                feedback_source: {
                    min: '请选择反馈来源'
                }
            }
        });
    });

    function checkTextarea() {
        var detailText = $("#detail").val();
        var feedback_time = $("#feedback_time").val();
        var create_time = $("#create_time").val();

//        if (null == detailText || "" == detailText.trim()) {
//            $("#feedbackTimeError").css('display', 'none');
//            $("#detailError").css('display', 'block');
//            return false;
//        } else
        if (null == create_time || "" == create_time.trim()) {
            $("#createTimeError").css('display', 'block');
            $("#detailError").css('display', 'none');
            return false;
        } else if (null == feedback_time || "" == feedback_time.trim()) {
            $("#feedbackTimeError").css('display', 'block');
            $("#detailError").css('display', 'none');
            return false;
        } else {
            $("#feedbackTimeError").css('display', 'none');
            $("#detailError").css('display', 'none');
            $("#createTimeError").css('display', 'none');
            return true;
        }
    }

    //按钮先执行验证再提交表单
    $("#submitBtn").click(function () {

        if ($("#demandForm").valid() && checkTextarea()) {

            var title =  $("#title").find("option:selected").text();
            var opId = $("#opId").val();
            /*     var classId = $("[name=classId]").val();
             var brandClass = $("[name=brandClass]").val(); */
            var detail = $("#detail").val();
            //var askResult = $("#classId").find("option:selected").text();

            var feedback_name = $("#feedback_name").val();
            var demand_product = $("#demand_product").val();
            var demand_product_name = $("#demand_product").find("option:selected").text();
            var demand_type = $("#demand_type").val();
            //var demand_product = $("#demand_product").find("option:selected").text();
            //var demand_type = $("#demand_type").find("option:selected").text();
            //var brandRecommend = $('input[name="brandRecommend"]:checked ').val();
            var feedback_city = $("#feedback_city").find("option:selected").text();
            var feedback_time = $("#feedback_time").val();
            //var feedback_source = $("#feedback_source").val();
            var feedback_source = $("#feedback_source").find("option:selected").text();
            var department = $("#department").find("option:selected").text();
            var departmentId = $("#department").val();
            var remark = $("#remark").val();
            var priority = $("#priority").val();
            var principal = $("#principal").find("option:selected").text();
            var principalId = $("#principal").val();
            var currentPrincipal = $("#currentPrincipal").find("option:selected").text();
            var currentPrincipalId = $("#currentPrincipal").val();
            var createTime = $("#create_time").val();
            var demandType = $("#demandType").val();
            var oldDemandType = $("#oldDemandType").val();
            var status = $("#status").val();
            var opType = $("#opType").find("option:selected").text();

            var args = {
                "feedbackSource": feedback_source,
                "feedbackName": feedback_name,
                "feedbackCity": feedback_city,
                "demandProduct": demand_product,
                "feedbackTime": feedback_time,
                "detail": detail,
                "title": title,
                "createTime": createTime,
                "department": department,
                "departmentId": departmentId,
                "priority": priority,
                "principal": principal,
                "principalId": principalId,
                "demandProductName": demand_product_name,
                "id": opId,
                "demandType": demandType
            }


            if (demandType == 1) {

                if ("请选择--" == departmentId.trim()) {
                    $("#departError").css('display', 'block');
                    return;
                }
                else {
                    $("#departError").css('display', 'none');
                }

                if ("请选择--" == principal.trim()) {
                    $("#priError").css('display', 'block');
                    return;
                }
                else {
                    $("#priError").css('display', 'none');
                }
            }


            //根据选择的选项卡改变提交的ACTION
            var url = "managerUpdate.html";

            if (demandType == 2) {
                args = {
                    "feedbackSource": feedback_source,
                    "feedbackName": feedback_name,
                    "feedbackCity": feedback_city,
                    "demandProduct": demand_product,
                    "feedbackTime": feedback_time,
                    "createTime": createTime,
                    "detail": detail,
                    "title": title,
                    "currentPrincipal": currentPrincipal,
                    "currentPrincipalId": currentPrincipalId,
                    "demandProductName": demand_product_name,
                    "id": opId,
                    "demandType": demandType
                }
            } else if (demandType == 3) {
                var statusText = "待处理";
                if (2 == status){
                    statusText = "已处理";
                }
                args = {
                    "feedbackSource": feedback_source,
                    "feedbackName": feedback_name,
                    "feedbackCity": feedback_city,
                    "demandProduct": demand_product,
                    "feedbackTime": feedback_time,
                    "createTime": createTime,
                    "detail": detail,
                    "title": title,
                    "remark": remark,
                    "demandProductName": demand_product_name,
                    "id": opId,
                    "demandType": demandType,
                    "status": status,
                    "statusText":statusText,
                    "optype": opType
                }
            }

            //加载进度条
            layer.load(2, {
                shade: [0.2, '#999999'] //0.1透明度的白色背景
            });
            $.post(url, args, function (data) {
                data = jQuery.parseJSON(data);
                //保存成功
                if (data.code == 1) {
                    layer.alert(data.msg, function () {
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                    });

                } else {
                    //失败
                    layer.alert(data.msg);
                    layer.closeAll('loading');
                }
            });

        }
    });


    function p(s) {
        return s < 10 ? '0' + s : s;
    }

    function getDate() {
        var myDate = new Date();
        //获取当前年
        var year = myDate.getFullYear();
        //获取当前月
        var month = myDate.getMonth() + 1;
        //获取当前日
        var date = myDate.getDate();
        var h = myDate.getHours();       //获取当前小时数(0-23)
        var m = myDate.getMinutes();     //获取当前分钟数(0-59)
        var s = myDate.getSeconds();

        var now = year + '-' + p(month) + "-" + p(date) + " " + p(h) + ':' + p(m) + ":" + p(s);
        return now;
    }

</script>
</body>

</html>